import request from '@/utils/request';

/**
 * 枚举获取
 */
export async function queryOptionsKeys(
  data: { key: string[]; parent?: string }, //key列表，LASTEST_TOP、PACKAGE_LIMIT、PRICE_LIMIT、ORDER_LIMIT、REUSAVLE_TYPE、OFFER_RESET
  options?: API.baseOption,
) {
  return request<API.OptionsKeysItem[]>('/options/keys', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券门店组列表
 */
export async function queryOptionsStoreGrouplist(
  data: { brandId: string },
  options?: API.baseOption,
) {
  return request<API.OptionsStoreGrouplistItem[]>('/options/store-group-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 活动组类型列表
 */
export async function queryOptionsActivityGroupTypeList(options?: API.baseOption) {
  return request<API.OptionsActivityGroupTypeListItem[]>('/options/activity-group-type-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 活动组列表
 */
export async function queryOptionsActivityGrouplist(
  data: { brandId: string; groupTypeId: string },
  options?: API.baseOption,
) {
  return request<API.OptionsActivityGroupItem[]>('/options/activity-group-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 渠道查询
 */
export async function queryOptionsChannelList(options?: API.baseOption) {
  return request<API.OptionsChannelListItem[]>('/options/channel-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 券标签
 */
export async function queryOptionsCouponTagList(options?: API.baseOption) {
  return request<API.OptionsCouponTagListItem[]>('/options/coupon-tag-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 品牌
 */
export async function queryOptionsBrandList(options?: API.baseOption) {
  return request<API.OptionsBrandListItem[]>('/options/brand-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 发放平台
 */
export async function queryOptionsPlaceChannelList(
  data: { brandName?: string },
  options?: API.baseOption,
) {
  return request<API.OptionsPlaceChannelListItem[]>('/options/place-channel-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券使用渠道描述
 */
export async function queryOptionsUseChannelList(
  data: { brandName?: string },
  options?: API.baseOption,
) {
  return request<API.OptionsUseChannelListItem[]>('/options/use-channel-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 租户列表查询
 */
export async function queryOptionsTenantList(data: { brandId?: string }, options?: API.baseOption) {
  return request<API.OptionsTenantListItem[]>('/options/tenant-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 业务类型
 */
export async function queryOptionsBusinessTypeList(options?: API.baseOption) {
  return request<API.OptionsBusinessTypeListItem[]>('/options/business-type-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 券码用途
 */
export async function queryOptionsCouponUseCategoryList(options?: API.baseOption) {
  return request<API.OptionsCouponUseCategoryListItem[]>('/options/coupon-use-category-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 区域
 */
export async function queryOptionsRegionList(options?: API.baseOption) {
  return request<API.OptionsRegionListItem[]>('/options/region-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 券过滤标签
 */
export async function queryOptionsFilterTagList(options?: API.baseOption) {
  return request<API.OptionsFilterTagListItem[]>('/options/filter-tag-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 余额归属品牌
 */
export async function queryOptionsFinanceBrandList(options?: API.baseOption) {
  return request<API.OptionsFinanceBrandListItem[]>('/options/finance-brand-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 收入类型
 */
export async function queryOptionsRevenueTypeList(options?: API.baseOption) {
  return request<API.OptionsRevenueTypeListItem[]>('/options/revenue-type-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 卡包栏位
 */
export async function queryOptionsUsetabList(data: { brandId: string }, options?: API.baseOption) {
  return request<API.OptionsUsetabListItem[]>('/options/usetab-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 限制使用规则明细
 */
export async function queryOptionsUsemarketingList(
  data: { type: number }, //0,所有，1：限制使用规则明细，2：限制使用高级明细
  options?: API.baseOption,
) {
  return request<API.OptionsUsemarketingListItem[]>('/options/usemarketing-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 日期组
 */
export async function queryOptionsDategroupList(
  data: { brandId: string },
  options?: API.baseOption,
) {
  return request<API.OptionsDategroupListItem[]>('/options/dategroup-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 键位模板
 */
export async function queryOptionsActivityProductkeyList(
  data: { brandId?: string },
  options?: API.baseOption,
) {
  return request<API.OptionsActivityProductkeyListItem[]>('/options/activity-productkey-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 产品ID扩展属性
 */
export async function queryOptionsExtandvalueIdList(options?: API.baseOption) {
  return request<API.OptionsExtandvalueIdListItem[]>('/options/extandvalue-id-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 *  扩展属性
 */
export async function queryOptionsExtandvalueInfoList(options?: API.baseOption) {
  return request<API.OptionsExtandvalueInfoListItem[]>('/options/extandvalue-info', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 餐厅类型
 */
export async function queryOptionsStoreTypeList(
  data: { brandId?: string },
  options?: API.baseOption,
) {
  return request<API.OptionsStoreTypeListItem[]>('/options/store-type-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 场景
 */
export async function queryOptionsScenarioList(options?: API.baseOption) {
  return request<API.OptionsScenarioListItem[]>('/options/scenario-list', {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 用餐时间ID
 */
export async function queryOptionsDaypartList(
  data: { brandId?: string },
  options?: API.baseOption,
) {
  return request<API.OptionsDaypartListItem[]>('/options/daypart-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 规则名称
 */
export async function queryOptionsNotifyRuleList(
  data: { brandName?: string },
  options?: API.baseOption,
) {
  return request<API.OptionsNotifyRuleListItem[]>('/options/notify-rule-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券配置模板
 */
export async function queryProfileTemp(
  data: { brandName: string; placeChannelName: string },
  options?: API.baseOption,
) {
  return request<API.ProfileTempDetail>('/profile/profile-temp', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券配置使用渠道模板
 */
export async function queryUseChannelTemp(
  data: { brandName: string; useChannelName: string },
  options?: API.baseOption,
) {
  return request<string>('/profile/use-channel-temp', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 配置信息查询
 */
export async function queryConfigInfo(data: { key: string }, options?: API.baseOption) {
  return request<string>('/options/config-info', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券配置编辑接口
 */
export async function profileEdit(
  data: { scenarioDesc: API.ScenarioDesc; realProfileInfo: API.RealProfileInfo },
  options?: API.baseOption,
) {
  return request<API.ResProfileEdit>('/profile/edit', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券配置列表查询接口
 */
export async function profileSearch(data: API.ProfileSearchInfo, options?: API.baseOption) {
  return request<API.ProfileListItem[]>('/profile/search', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券配置列表查询接口
 */
export async function profileSearchWithPage(data: API.ProfileSearchInfo, options?: API.baseOption) {
  return request<any>('/profile/searchWithPage', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券配置激活接口
 */
export async function profileActivate(data: { activityIds: string }, options?: API.baseOption) {
  return request<string>('/profile/activate', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

// 详情查询结果---开始

/**
 * 券限制门店列表
 */
export async function getActivityStoreList(data: { activityId: string }, options?: API.baseOption) {
  return request<any>('/activity/store-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券限制日期列表
 */
export async function getActivityDateList(data: { activityId: string }, options?: API.baseOption) {
  return request<any>('/activity/date-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券限制时间列表
 */
export async function getActivityTimeList(data: { activityId: string }, options?: API.baseOption) {
  return request<any>('/activity/time-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券限制星期列表
 */
export async function getActivityDweekList(data: { activityId: string }, options?: API.baseOption) {
  return request<any>('/activity/dweek-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券限制天数列表
 */
export async function getActivityDmonthList(
  data: { activityId: string },
  options?: API.baseOption,
) {
  return request<any>('/activity/dmonth-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券使用次数限制
 */
export async function getActivityReusableList(
  data: { activityId: string },
  options?: API.baseOption,
) {
  return request<any>('/activity/reusable-count-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 查询券NeedGenasynfile
 */
export async function getNeedGenasynfile(data: { activityId: string }, options?: API.baseOption) {
  return request<any>('/activity/queryNeedGenasynfile', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

// 2.2.7 导出 /coupon-config/profile/export
export async function profileExport(data: any, options?: API.baseOption) {
  return request<any>('/profile/export', {
    responseType: 'blob',
    getResponse: true,
    method: 'POST',
    data,
    ...(options || {}),
  });
}

// 详情查询结果---结束

/**
 * activity数量查询
 */
export async function queryCount(data: { activityId: string }, options?: API.baseOption) {
  return request<API.QueryCountRes>('/activity/query-count', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 券配置同步PRE
 */
export async function profileToUat(data: { activityId: string }, options?: API.baseOption) {
  return request<API.RrofileToUatRes>('/profile/profile-to-uat', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

// 键位模版---开始
/**
 * 2.9.1 键位模板查询/coupon-config/productkey/search
 */
export async function productkeySearch(
  data: { brandId: string; productkeyName: string },
  options?: API.baseOption,
) {
  return request<API.BasePaginationRes<API.ProductkeyListItem>>('/productkey/search', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.2 键位模板编辑/coupon-config/productkey/edit
 */
export async function productkeyEdit(data: API.ProductkeyEditInfo, options?: API.baseOption) {
  return request<string>('/productkey/edit', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.3 同步activity数量统计/coupon-config/productkey/activity-count
 */
export async function activityCount(data: { id: string }, options?: API.baseOption) {
  return request<any>('/productkey/activity-count', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.4 同步activity/coupon-config/productkey/sync-activity
 */
export async function syncActivity(data: { id: string }, options?: API.baseOption) {
  return request<API.BasePaginationRes<API.SyncActivityListItem>>('/productkey/sync-activity', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.5 同步子规则数量统计/coupon-config/productkey/rule-count
 */
export async function ruleCount(data: { id: string }, options?: API.baseOption) {
  return request<any>('/productkey/rule-count', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.6 同步子规则/coupon-config/productkey/sync-rule
 */
export async function syncRule(data: { id: string }, options?: API.baseOption) {
  return request<string>('/productkey/sync-rule', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.7 刷新activity/coupon-config/productkey/refresh-activity
 */
export async function refreshActivity(data: { id: string }, options?: API.baseOption) {
  return request<string>('/productkey/refresh-activity', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.8 同步PRE/coupon-config/productkey/sync-uat
 */
export async function syncUat(data: { id: string }, options?: API.baseOption) {
  return request<string>('/productkey/sync-uat', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.9 键位模板删除/coupon-config/productkey/delete
 */
export async function productkeyDelete(data: { id: string }, options?: API.baseOption) {
  return request<string>('/productkey/delete', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.10 键位模板导出profile/coupon-config/productkey/export-profile
 */
export async function exportProfile(data: { id: string }, options?: API.baseOption) {
  return request<string>('/productkey/export-profile', {
    getResponse: true,
    responseType: 'blob',
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 *2.9.11 键位模板导出activity/coupon-config/productkey/export-activity
 */
export async function exportActivity(data: { id: string }, options?: API.baseOption) {
  return request<string>('/productkey/export-activity', {
    getResponse: true,
    responseType: 'blob',
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.12 键位模板导出子规则/coupon-config/productkey/export-rule
 */
export async function exportRule(data: { id: string }, options?: API.baseOption) {
  return request<string>('/productkey/export-rule', {
    getResponse: true,
    responseType: 'blob',
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 2.9.13 键位模板详情/coupon-config/productkey/detail
 */
export async function productkeyDetail(data: { id: string }, options?: API.baseOption) {
  return request<any>('/productkey/detail', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

// 键位模版---结束

/**
 * 2.4.28 服务器标识列表 /coupon-config/options/site_tag-list
 */
export async function optionsSiteTagList(data: {}, options?: API.baseOption) {
  return request<any>('/options/site_tag-list', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}
